{"version":3,"file":"static/chunks/pages/[...path]-c740f023cd8ef582.js","mappings":"qFACA,CAAAA,OAAAC,QAAA,CAAAD,OAAAC,QAAA,MAAAC,IAAA,EACA,aACA,WACA,OAAeC,EAAQ,KACvB,EACA,iKCMe,SAASC,EAAaC,CAAiC,KAAjC,CAAEC,cAAAA,CAAa,CAAEC,eAAAA,CAAc,CAAE,CAAjCF,EAC3BG,EAAYC,EAAAA,CAAc,CAACH,EAAc,QAC/C,EAGO,GAAAI,EAAAC,GAAA,EAACH,EAAAA,CAAAA,EAAAA,EAAAA,CAAAA,EAAAA,CAAAA,EAAcD,IAFX,GAAAG,EAAAE,IAAA,EAACC,KAAAA,WAAG,aAAWP,EAAc,eAG5C","sources":["webpack://_N_E/?edb5","webpack://_N_E/./pages/[...path].js"],"sourcesContent":["\n (window.__NEXT_P = window.__NEXT_P || []).push([\n \"/[...path]\",\n function () {\n return require(\"private-next-pages/[...path].js\");\n }\n ]);\n if(module.hot) {\n module.hot.dispose(function () {\n window.__NEXT_P.push([\"/[...path]\"])\n });\n }\n ","import querystring from 'querystring';\nimport { serverSideTranslations } from 'next-i18next/serverSideTranslations';\nimport {\n getPage,\n getRedirect,\n getAllPages,\n WagtailApiResponseError,\n} from '../api/wagtail';\nimport LazyContainers from '../containers/LazyContainers';\n\nconst isProd = process.env.NODE_ENV === 'production';\n\nexport default function CatchAllPage({ componentName, componentProps }) {\n const Component = LazyContainers[componentName];\n if (!Component) {\n return <h1>Component {componentName} not found</h1>;\n }\n return <Component {...componentProps} />;\n}\n\n// For SSR\nexport async function getServerSideProps({ req, params, res, locale }) {\n let path = params?.path || [];\n path = path.join('/');\n\n const translations = await serverSideTranslations(locale, ['common']);\n\n const { host } = req.headers;\n let queryParams = new URL(req.url, `https://${host}`).search;\n if (queryParams.indexOf('?') === 0) {\n queryParams = queryParams.substr(1);\n }\n queryParams = querystring.parse(queryParams);\n\n queryParams = {\n ...queryParams,\n host,\n };\n\n // Try to serve page\n try {\n const {\n json: { componentName, componentProps, redirect, customResponse },\n headers,\n } = await getPage(path, queryParams, {\n headers: {\n cookie: req.headers.cookie,\n host,\n },\n });\n\n // Forward any cookie we encounter\n const cookies = headers.get('set-cookie');\n if (cookies) {\n res.setHeader('Set-Cookie', cookies);\n }\n\n if (customResponse) {\n const { body, body64, contentType } = customResponse;\n res.setHeader('Content-Type', contentType);\n res.statusCode = 200;\n res.write(body64 ? Buffer.from(body64, 'base64') : body);\n res.end();\n\n return { props: { ...translations } };\n }\n\n if (redirect) {\n const { destination, isPermanent } = redirect;\n return {\n redirect: {\n destination: destination,\n permanent: isPermanent,\n },\n };\n }\n\n return { props: { componentName, componentProps, ...translations } };\n } catch (err) {\n if (!(err instanceof WagtailApiResponseError)) {\n throw err;\n }\n\n // When in development, show django error page on error\n if (!isProd && err.response.status >= 500) {\n const html = await err.response.text();\n return {\n props: {\n componentName: 'PureHtmlPage',\n componentProps: { html },\n ...translations,\n },\n };\n }\n\n if (err.response.status >= 500) {\n throw err;\n }\n }\n\n // Try to serve redirect\n try {\n const { json: redirect } = await getRedirect(path, queryParams, {\n headers: {\n cookie: req.headers.cookie,\n host,\n },\n });\n const { destination, isPermanent } = redirect;\n return {\n redirect: {\n destination: destination,\n permanent: isPermanent,\n },\n };\n } catch (err) {\n if (!(err instanceof WagtailApiResponseError)) {\n throw err;\n }\n\n if (err.response.status >= 500) {\n throw err;\n }\n }\n\n // Serve 404 page\n return { notFound: true };\n}\n\n// For SSG\n/*\nexport async function getStaticProps({ params, preview, previewData }) {\n params = params || {};\n let path = params.path || [];\n path = path.join(\"/\");\n\n const { json: pageData } = await getPage(path);\n return { props: pageData }\n}\n\nexport async function getStaticPaths() {\n const { json: data } = await getAllPages();\n\n let htmlUrls = data.items.map(x => x.relativeUrl);\n htmlUrls = htmlUrls.filter(x => x);\n htmlUrls = htmlUrls.map(x => x.split(\"/\"));\n htmlUrls = htmlUrls.map(x => x.filter(y => y))\n htmlUrls = htmlUrls.filter(x => x.length)\n\n const paths = htmlUrls.map(x => (\n { params: { path: x } }\n ));\n\n return {\n paths: paths,\n fallback: false,\n };\n}\n*/\n"],"names":["window","__NEXT_P","push","__webpack_require__","CatchAllPage","param","componentName","componentProps","Component","LazyContainers","react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__","jsx","jsxs","h1"],"sourceRoot":""}